package ca.ualberta.cs.CLRDB.interfaces;

import java.sql.Connection;
import java.util.HashMap;

import ca.ualberta.cs.BibTex.BibTex;
import ca.ualberta.cs.CLRDB.AuthoringManagement;
import ca.ualberta.cs.CLRDB.BibTexManagement;
import ca.ualberta.cs.CLRDB.ReadingManagement;
import ca.ualberta.cs.CLRDB.TagsManagement;

public interface ResourceAccess extends EntityRelAccess {

	/**
	    * When bib is not provided
	    * @param url
	    * @param con
	    * @return -1: does not exists, -2: an exception, other: resourceId
	    */
	public int resourceExists(String url, Connection con);
	
	/**
	    * checks whether a resource with exactly this bib and url already exists
	    * @param bib
	    * @param con
	    * @return -1: does not exists, -2: an exception, resourceId: exists
	    */
	   public int resourceExists(Integer bibtexId, String url, Connection con);
	   
	   /**
	    * @param bib
	    * @param connection
	    * @return id of the added resource, or -1 in case of exception
	    */
	   public int addResourceWithBibtex(BibTex bib, String url, Connection con);
	   
	   public int addResourceWithBibtexId(Integer bibtexId, BibTex bib, String url, Connection con);
	   
	   /**
	    * When bib is not provided
	    * @param url
	    * @param connection
	    * @return id of the added resource, or -1 in case of exception
	    */
	   public int addResource(String url, String docDigest, String textDigest, Connection con);
	   public void updateResourceDigest(Integer resourceId, String docDigest, String textDigest, Connection con);
	   
	   /**
	    * 
	    * @param bib
	    * @param resourceId
	    * @return first author
	    */
	   public int addAuthorsOfResource(BibTex bib, Integer resourceId);
	   
	   public int addOrUpdateResource(BibTex bib, HashMap<String,String> paperInfo, String url);
	   
	   //getters:
	   public AuthoringManagement getAuthoringManagement();
	   public TagAccess getTagsManagement();
	   public BibTexManagement getBibTexManagement();
	   public ReadingManagement getReadingManagement();
}
